package com.mingqijia.gassafety.webserver.service.cmp;

import cn.hutool.core.date.DateUtil;
import com.gap.basic.exception.BizException;
import com.mingqijia.gassafety.webserver.dto.NotifyDTO;
import com.mingqijia.gassafety.webserver.request.cmp.notify.DataReportRequest;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * CMP平台上报数据回调 Service
 *
 * @author zhufeng
 * @since 2022/8/1
 */
public interface CmpDataNotifyService {

    /**
     * CMP回调接口数据落库处理
     * @param dataReportRequest
     * @throws BizException
     *
     */
    NotifyDTO saveReportData(DataReportRequest dataReportRequest) throws BizException;

    void notifyState(NotifyDTO notifyDTO);

    default Date localDateTimeToDate(LocalDateTime time){
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String timeString = pattern.format(time);
        Date date = DateUtil.parse(timeString, "yyyy-MM-dd HH:mm:ss");
        return date;
    }
}
